I'm trying to convert a jpg image acquired from the internet into an HBITMAP. I'd like to be able to check the pixel by pixel values of the image (specifically I'm looking for blue pixels in a jpg image)

I successfully grap the JPG image from the internet with this function:
Code:
HBITMAP Internet::getFromInternet(std::string gal)
{
     hInternet = InternetOpen( "GINA: Version 0.1", INTERNET_OPEN_TYPE_DIRECT, NULL, 0,0);
     
     std::string temp = gal  + ".overview.jpg";
     gal = "http://www.imperialconflict.com/images/Galaxies/";
     gal += temp;
     MessageBox(NULL,gal.c_str(),"",MB_OK);
     
     //get size of file
     hFile = InternetOpenUrl(hInternet, gal.c_str(), NULL, 0, 0, 0);
     DWORD sizeBuffer;
     DWORD length = sizeof(sizeBuffer);
     BYTE *buffer = NULL;
     
     bool succeeds = HttpQueryInfo(hFile, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, (LPVOID)&sizeBuffer, &length, NULL);
     if (!succeeds)
     {
        throw "Unable to fetch map";
        return (HBITMAP) NULL;
     }
     buffer = new BYTE[sizeBuffer];
     
     //initialize all elements to 0
     for (int i = 0; i < sizeBuffer; i++)
         buffer[i] = 0;
          
     //get file     
     DWORD bytesRead;
     DWORD bytesToRead = sizeBuffer;
     if (hFile)
     {
               InternetReadFile(hFile, buffer, bytesToRead, &bytesRead);
     }
     else
         throw "Unable to grab overview image";
     InternetCloseHandle(hFile);
     InternetCloseHandle(hInternet);
     return loadImage(buffer);
}
It calls this function loadImage(BYTE*)
Code:
HBITMAP Internet::loadImage(BYTE* jpgData)
{
        /* TODO (#1#): Fix access violaion in code below.
        May have something to do with how I'm passing jpgData*/
        MessageBox(NULL,"Load Image 1", "", NULL); 
        IPicture* pic = 0;
        IStream* stream = 0;
        IPersistStream* ps = 0; 
        void* pp = (void*)jpgData;
        MessageBox(NULL,"Load Image 3", "", NULL); 
        OleLoadPicture(stream,0,false,IID_IPicture,(void**)&pic);
        MessageBox(NULL,"Load Image 4", "", NULL);
        stream->Release(); //access violation here?
        MessageBox(NULL,"Load Image 5", "", NULL);
        HBITMAP hB = 0;
        MessageBox(NULL,"Load Image 6", "", NULL);
        pic->get_Handle((unsigned int*)&hB);
        MessageBox(NULL,"Load Image 7", "", NULL);
        // Copy the image. Necessary
        HBITMAP hBB = (HBITMAP)CopyImage(hB,IMAGE_BITMAP,0,0,LR_COPYRETURNORG);
        pic->Release();
        delete [] jpgData; //IMPORTANT
        return hBB;
}
stream->Release() causes an access violation. I have no idea why and googling hasn't revealed any answers.

Is their another way to check the data at a pixel without converting a jpg into an HBITMAP? Maybe some incredibly magical libraries?